/**
  *  Copyright (c) 2017-2022 Rushang Co.Ltd All Rights Reserved.
 */
package com.rshang.rsdp.config;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import com.baomidou.mybatisplus.plugins.PaginationInterceptor;

/**
 * 功能简介：mybatis-plus配置类<br/>
 * @author zhangjun
 * @create 2017年8月2日上午9:25:35
 * 
 */
@Configuration
@EnableTransactionManagement 
@MapperScan("com.rshang.rsdp.mapper*")
public class RsdpMyBatisPlusConfig {
	
	
	/*@Autowired  
    private DataSource dataSource;  
   
    @Autowired  
    private MybatisPlusProperties properties;  
   
    @Autowired  
    private ResourceLoader resourceLoader = new DefaultResourceLoader();  
   
    @Autowired(required = false)  
    private Interceptor[] interceptors;  
   
    @Autowired(required = false)  
    private DatabaseIdProvider databaseIdProvider;*/
   
	@Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
	}
    /** 
     * 这里全部使用mybatis-autoconfigure 已经自动加载的资源。不手动指定 
     * 配置文件和mybatis-boot的配置文件同步 
     * @return 
     * @throws Exception 
     */ 
    /*@Bean  
    public SqlSessionFactory mybatisSqlSessionFactoryBean() throws Exception {
    	System.out.println("mybatisSqlSessionFactoryBean");
        MybatisSqlSessionFactoryBean mybatisPlus = new MybatisSqlSessionFactoryBean();  
        mybatisPlus.setDataSource(dataSource);  
        mybatisPlus.setVfs(SpringBootVFS.class);  
        if (StringUtils.hasText(this.properties.getConfigLocation())) {  
            mybatisPlus.setConfigLocation(this.resourceLoader.getResource(this.properties.getConfigLocation()));  
        }  
        mybatisPlus.setConfiguration(properties.getConfiguration());
        PaginationInterceptor pagination = new PaginationInterceptor();
        if (!ObjectUtils.isEmpty(this.interceptors)) {  
            mybatisPlus.setPlugins(this.interceptors);  
        }  
        mybatisPlus.setPlugins(new Interceptor[]{
        	      pagination
        });
        MybatisConfiguration mc = new MybatisConfiguration();  
        mc.setDefaultScriptingLanguage(MybatisXMLLanguageDriver.class);  
        mybatisPlus.setConfiguration(mc);  
        if (this.databaseIdProvider != null) {  
            mybatisPlus.setDatabaseIdProvider(this.databaseIdProvider);  
        }  
        if (StringUtils.hasLength(this.properties.getTypeAliasesPackage())) {  
            mybatisPlus.setTypeAliasesPackage(this.properties.getTypeAliasesPackage());  
        }  
        if (StringUtils.hasLength(this.properties.getTypeHandlersPackage())) {  
            mybatisPlus.setTypeHandlersPackage(this.properties.getTypeHandlersPackage());  
        }  
        if (!ObjectUtils.isEmpty(this.properties.resolveMapperLocations())) {  
            mybatisPlus.setMapperLocations(this.properties.resolveMapperLocations());  
        }  
		if (!(ObjectUtils.isEmpty(this.properties.getGlobalConfig()))) {
			mybatisPlus.setGlobalConfig(this.properties.getGlobalConfig().convertGlobalConfiguration());
		}

        return mybatisPlus.getObject();  
    } */
}
